<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
<form id="test">
    选择文件:<input data-role="none" type="file" name="file" width="120px">
    <button data-role="none" onclick="testUpload();">测试</button>
</form>

<script>
    function testUpload(){
        var form = new FormData(document.getElementById("test"));

        $.ajax({
            url : "http://localhost:8080/home/test.action",
            data : form,
            type : 'post',
            processData:false,
            contentType:false,
            success : function(data){
                alert("成功")
            },
            error : function(data){

            }
        });
    }
</script>
</body>
</html>